package com.george.shiro.model.service.impl;

import com.george.shiro.model.entity.Role;
import com.george.shiro.model.dao.RoleMapper;
import com.george.shiro.model.service.IRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.george.shiro.vo.RoleConditionVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author george
 * @since 2019-05-21
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Override
    public List<Role> findRoleListByUserId(Long userId) {
        List<Role> roles = this.baseMapper.selectRolesByUserId(userId);
        return roles;
    }

    @Override
    public PageInfo<Role> findPageBreakByCondition(RoleConditionVO vo) {
        PageHelper.startPage(vo.getPageNumber(), vo.getPageSize());
        List<Role> roles = this.baseMapper.findPageBreakByCondition(vo);
        PageInfo<Role> pageInfo = new PageInfo<>(roles);
        pageInfo.setList(roles);
        return pageInfo;
    }
}
